import PaginationDto from "apps/admin/src/dtos/pagination.dto";
import { ArrayMaxSize, ArrayMinSize, IsArray, IsBoolean, IsEmpty, IsNotEmpty, IsNumber, IsOptional, IsString, Max, MaxLength, Min, MinLength } from "class-validator";


class CommonDto {
    @MaxLength(30)
    @IsString()
    @IsOptional()
    name:string;

    @MaxLength(11)
    @IsString()
    @IsOptional()
    tel:string;

    @Min(0)
    @IsNumber({})
    @IsOptional()
    deptId:number;

    @IsArray()
    @IsOptional()
    depts:number[];

    @ArrayMaxSize(100)
    @IsArray()
    @IsOptional()
    roles:number[]


    @IsBoolean()
    @IsOptional()
    enable:boolean;

    @MaxLength(100)
    @IsString()
    @IsOptional()
    remark:string;
}

export class AddDto extends CommonDto {
    @MaxLength(30)
    @IsNotEmpty()
    @IsString()
    account:string;


    @MaxLength(30)
    @MinLength(6)
    @IsString()
    @IsOptional()
    password:string;
}

export class EditDto extends CommonDto {
    @MaxLength(30)
    @MinLength(6)
    @IsString()
    @IsOptional()
    password:string;
}


export class PageDto extends PaginationDto {
    @MaxLength(30)
    @IsString()
    @IsOptional()
    account:string;

    @MaxLength(30)
    @IsString()
    @IsOptional()
    name:string;
}

export class UpdateDto {
    @MaxLength(30)
    @IsString()
    @IsOptional()
    name:string;
}

export class ChangePwdDto {
    @IsString()
    oldpassword:string;

    @MaxLength(30)
    @MinLength(6)
    @IsString()
    password:string;
}